package com.heima.article.job;

import com.heima.article.service.HotArticleService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author XHui
 * @Since 2024/3/11 16:22
 * @Version 1.0
 */
@Slf4j
@Component
public class ComputeHotArticleJob {

    @Resource
    private HotArticleService hotArticleService;

    /**
     * 计算热点文章
     *
     * @param params 任务调度中心传递过来的参数
     * @return 返回 ReturnT的实例给调度中心
     */
    @XxlJob("computeHotArticleJob")
    public ReturnT computeHotArticle(String params) {
        log.info("热文章分值计算调度任务开始执行....");
        // 待实现热点文章分值计算任务
        hotArticleService.computeHotArticle();
        log.info("热文章分值计算调度任务完成....");
        return ReturnT.SUCCESS;
    }
}
